home *** CD-ROM | disk | FTP | other *** search
- /* ======================================================================
- DESC: Common Calendar Functions
-
- PLATFORMS: >= MS IE 4.0
- USAGE NOTES:
- ====================================================================== */
- var dowArray = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
- var baseDay = null;
- var baseMonth = null;
- var baseYear = null;
- var baseDow = null;
- var baseTime = null;
- var curMonth = null;
- var curYear = null;
- var curSelMonth = null;
- var curSelYear = null;
- var curDay = null;
- var UTxtArray = new Array("Minute(s) ","Hour(s)","Day(s)","Week(s)");
- var UValArray = new Array(60000,3600000,86400000,604800000);
- var cHrs = 0; // specified hours
- var cMins = 0; // specified minutes
- var cSecs = 0; // specified seconds
- var selTime = null;
-
- /* Initialize Calendar Function */
- function Calendar_init(CName,mode){
- _param_ = new Object();
- _param_.name = CName;
- _param_.width = "215";
- _param_.height = "230";
- _param_.selDate = "";
- _param_.wdayFormat = "FirstLetter";
- _param_.textFont = "";
- _param_.textSize = "";
- _param_.textColor = "";
- _param_.selColor = "lightgrey";
- _param_.border = "0";
- _param_.testMode = "off";
- if ( arguments.length == 2 ) {
- _param_.dirMode = mode;
- }
- else {
- _param_.dirMode = null;
- }
- co = new com_netobjects_Calendar(_param_);
- return co;
- }
-
- /* Event Handler for Calendar Date/Month change */
- function processSelDate(selMonth, selDay, selYear, DFobj, dirMode) {
- /* Verify the selection */
- if ( selMonth < baseMonth && selYear == baseYear && dirMode == false) {
- return false; // earlier than base month not allowed
- }
- else if ( selMonth > baseMonth && selYear == baseYear && dirMode == true) {
- return false; // later than base month not allowed
- }
- if ( selMonth != curMonth ) { // New month selected
- curMonth = selMonth; // set new month
- curYear = selYear;
- return true; // render new month
- }
- if ( selDay < baseDay && selMonth == baseMonth && dirMode == false ) {
- return false; // earlier day then base day not allowed
- }
- if ( selDay > baseDay && selMonth == baseMonth && dirMode == true ) {
- return false; // later day then base day not allowed
- }
-
- /* New valid date selected */
- curDay = selDay; // save it
- dOb = new Date(selYear,selMonth,selDay); // selected date
- dow = dOb.getDay(); // determine day of week
- selTime = dOb.getTime(); // determine msecs since 1/1/70
-
- /* Update the Date field */
- DFobj.value = " " + dowArray[dow] + " " + DFobj.CalObj.getSelDate();
- processCalendarClick(DFobj); // close calendar
- checkEnableSchedButton(); // Enable Schedule Button?
- return false; // no rendering
- }
-
- /* Process Click on Start Date Field */
- function processCalendarClick(DFobj) {
- if ( DFobj.className == "idis" ) {
- return;
- }
- calname = DFobj.calendar;
- if ( document.all[calname].CalState == "0" ) { // if closed
- getTodayDate();
- document.all[calname].CalState = "1"; // opened
- document.all[calname].innerHTML = "";
- document.all[calname].style.display="";
- DFobj.CalObj.textSize = 2;
- DFobj.CalObj.open(DFobj);
- DFobj.CalObj.onSelDate = processSelDate; // set event handler
- curSelMonth = curMonth = DFobj.CalObj.curMonth; // current Month and Year displayed
- curSelYear = curYear = DFobj.CalObj.curYear;
- curDay = DFobj.CalObj.curDay;
- }
- else {
- document.all[calname].CalState = "0"; // closed
- document.all[calname].style.display="none";
- }
- }
-
- /* Display Time Specified in cHrs, cMins, cSecs */
- function displaySpecifiedTime(fn) {
- cM = (cHrs > 11) ? "PM" : "AM";
- CH = (cHrs > 11) ? cHrs-12 : cHrs;
- CH = (CH == 0) ? 12 : CH;
- cMins = (cMins < 10) ? "0"+cMins : cMins;
- cSecs = (cSecs < 10) ? "0"+cSecs : cSecs;
- CH = (CH < 10) ? " "+CH : CH;
- document.all[fn].value = " " + CH + ":" + cMins + " " + cM;
- }
-
- /* Process Click on Time Field */
- function processTimeClick(Tpre,Tfn) {
- if ( document.all[Tfn].TimeState == "0" ) { // TimeState, if closed
- if ( document.all[Tfn].className == "idis" ) {
- return; // ignore open if disabled
- }
- if (document.all[Tfn].value == "") getTodayDate();
- document.all[Tfn].TimeState = "1"; // opened
- document.all[Tpre+"_TimHrs"].style.display="";
- document.all[Tpre+'_TempColon'].style.display="";
- document.all[Tpre+"_TimMins"].style.display="";
- document.all[Tpre+"_M"].style.display="";
- document.all[Tpre+"_closebutton"].style.display = "";
- //document.all[Tfn].style.display = "none";
- document.all[Tfn].size = "1";
- document.all[Tfn].value = "";
- document.all[Tfn].className = "idis";
-
- CH = (cHrs > 12) ? cHrs-12 : cHrs;
- CH = (CH == 0) ? 12 : CH;
- document.all[Tpre+"_TimHrs"].options[--CH].selected = "selected";
- document.all[Tpre+"_TimMins"].options[cMins].selected = "selected";
- cM = (cHrs > 11 && cHrs < 24) ? 1 : 0;
- document.all[Tpre+"_M"].options[cM].selected = "selected";
- document.all[Tpre+"_TimHrs"].focus();
- }
- else {
- document.all[Tfn].TimeState = "0"; // closed
- cHrs = document.all[Tpre+"_TimHrs"].selectedIndex+1; // get selected option
- cHrs = (cHrs == 12) ? 0 : cHrs; // Hr between 0 and 11
- cMins = document.all[Tpre+"_TimMins"].selectedIndex;
- cSecs = 0;
- if ( (i = document.all[Tpre+"_M"].selectedIndex) == 1) //PM selected
- cHrs += 12; // adjust hours
- displaySpecifiedTime(Tfn);
-
- document.all[Tpre+'_TempColon'].style.display="none";
- document.all[Tpre+"_TimHrs"].style.display="none";
- document.all[Tpre+"_TimMins"].style.display="none";
- document.all[Tpre+"_TimSecs"].style.display="none";
- document.all[Tpre+"_M"].style.display="none";
- document.all[Tpre+"_closebutton"].style.display = "none";
- //document.all[Tfn].style.display = "";
- document.all[Tfn].size = "10";
- document.all[Tfn].className = "";
- }
- checkEnableSchedButton(); // Enable Schedule Button?
- }
-
- function CreatTimeDropDowns(DDpre) {
- /* Create and Display Start Time dropdown selections */
- getTodayDate();
- dct = document.all[DDpre+"_TimHrs"];
- if ( dct.length == 0 ) { // if not defined yet
- for ( var i=1; i<=12; i++ ) { // Hrs drop down
- i = ( i < 10 ) ? " "+i : i;
- addElementToSelect(dct," "+i);
- }
- dct = document.all[DDpre+"_TimMins"];
- for ( i=0; i<=59; i++ ) { // Mins drop down
- i = ( i < 10 ) ? "0"+i : i;
- addElementToSelect(dct," "+i);
- }
- dct = document.all[DDpre+"_M"];
- addElementToSelect(dct,"AM");
- addElementToSelect(dct,"PM");
- }
- }
-
- function getTodayDate() {
- var dOb = new Date(); // today's date object
- cHrs = dOb.getHours(); // current time
- cMins = dOb.getMinutes();
- cSecs = dOb.getSeconds();
-
- baseDow = (baseDow == null) ? dOb.getDay() : baseDow;
- baseDay = (baseDay == null) ? dOb.getDate() : baseDay; // today's date
- baseMonth = (baseMonth == null) ? dOb.getMonth() : baseMonth;
- baseYear = (baseYear == null) ? dOb.getFullYear() : baseYear;
- baseTime = dOb.getTime();
- }
-
-
-
-
-